Skip to content

feat: add database indexes to assessment_attempt for common query paths - #1386

Merged
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
Horlarmmy:fix/add-assessment-attempt-indexes
Aug 29, 2026
Merged

feat: add database indexes to assessment_attempt for common query paths#1386
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
Horlarmmy:fix/add-assessment-attempt-indexes

Conversation

@Horlarmmy

Copy link
Copy Markdown
Contributor

Summary

Add indexes to assessment_attempt covering its common lookup and foreign-key columns (#1229).

Closes #1229

Problem

assessment_attempt had no indexes beyond the primary key. Columns used for lookups (studentId, assessmentId, status) forced sequential scans as the table grows.

Changes

Entity (src/assessment/entities/assessment-attempt.entity.ts):

  • Added @Index decorators for studentId, assessmentId, status, and a composite (studentId, assessmentId).

Migration (src/migrations/1802000000000-add-assessment-attempt-indexes.ts):

  • Creates 4 indexes via CREATE INDEX IF NOT EXISTS.
  • down() drops them in reverse order.
Index Columns Covers
IDX_assessment_attempt_studentId (studentId) "List my attempts"
IDX_assessment_attempt_assessmentId (assessmentId) FK lookups, "attempts for assessment"
IDX_assessment_attempt_status (status) Status-filtered queries
IDX_assessment_attempt_studentId_assessmentId (studentId, assessmentId) Duplicate-attempt check

Verification

  • tsc --noEmit passes
  • ESLint passes
  • validate-migrations.js passes (36 files)

@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@Horlarmmy Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Horlarmmy
Horlarmmy force-pushed the fix/add-assessment-attempt-indexes branch from 5477592 to db8a2e6 Compare August 29, 2026 21:02
@Horlarmmy
Horlarmmy force-pushed the fix/add-assessment-attempt-indexes branch from db8a2e6 to 4a7997b Compare August 29, 2026 21:10
@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Thank you for contributing to the project

@RUKAYAT-CODER
RUKAYAT-CODER merged commit 704e555 into rinafcode:main Aug 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add database indexes to the assessment-attempt entity

2 participants